//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.dao.wills;

import com.aidong.dao.base.ConditionMap;
import com.aidong.dao.base.OrderSet;
import com.aidong.dao.base.Pagination;
import com.aidong.model.wills.CustomerComplaint;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Repository;

@Repository
public class CustomerComplaintDao extends BaseDao<CustomerComplaint, Integer> {
    public CustomerComplaintDao() {
    }

    public List<CustomerComplaint> getListByMemberCode(String memberCode) {
        return this.queryList("memberCode=:p1", new Object[]{memberCode}, (new OrderSet()).desc("complainTime"), -1);
    }

    public boolean chkHasNewByMemberCode(String memberCode) {
        String sql = "select count(*) nn from CustomerComplaint where memberCode=:p1 and complainTime>dateadd(m,-3,getdate())";
        return ((Integer)this.getBySql(Integer.class, sql, new Object[]{memberCode})).intValue() > 0;
    }

    public void queryPageList(Pagination<CustomerComplaint> pg, ConditionMap cd) {
        ArrayList params = new ArrayList();
        String sqlw = cd.toSql(params);
        String sql = "select c.complainId, c.shopCode, c.memberCode, isnull(i.chName,e.custName) memberName, i.cardCode, isnull(i.mobile,e.mobile) mobile, c.type, c.priority, c.title, c.content, c.picUrls, c.complainTime, c.status, c.complainReason, c.riskMoney, c.procType, c.procResult, c.procNote, c.procUser, c.procTime, c.createUser, c.createTime, c.updateTime\nfrom CustomerComplaint c left join MemberInfo i on c.memberCode=i.memberCode\nleft join MemberEarnest e on c.earnestId=e.saleId\n" + (sqlw.length() > 0?"where " + sqlw:"") + " order by complainId desc";
        this.queryPageListBySql(CustomerComplaint.class, pg, sql, params.toArray());
    }

    public boolean updateStatus(int id, int status) {
        String hql = "update CustomerComplaint set status=:p1 where complainId=:p2";
        return this.updateByHql(hql, new Object[]{Integer.valueOf(status), Integer.valueOf(id)}) > 0;
    }
}
